#include "LogFileRocorder.h"

LogFileRocorder::LogFileRocorder(const std::string filename) :mfilename(filename)
{

}

void LogFileRocorder::doWrite(LogLevel level, const std::string& log, const std::string& file, int line)
{
	if (!Open())
	{
		std::cout << "文件打开失败" << std::endl;
		return;
	}
	mfs_ << this->mLogFormat->format(this->levelToStr(level), log, file, line) << std::endl;
	mfs_.close();
}

bool LogFileRocorder::Open()
{
	mfs_.open(mfilename, std::ios::app);
	if (mfs_.is_open())
	{
		return true;
	}
	else
	{
		return false;
	}
}
